import fetch from "@/config/fetch";

/**
 * 登陆
 */
//   export const login = data => fetch('/userLogin.do', data, 'POST');
export const login = data =>
    fetch("rechargeCardServer/manager/login", data, "POST");
//export const login = data => fetch('/admin/login', data, 'POST');

/**
 * 查询储值卡账户
 */
export const getCustomers = data =>
    fetch("rechargeCardServer/manager/getCustomers", data, "POST");

/**
 * 查询账户交易记录列表
 */
export const getTradeInfoList = data =>
    fetch("rechargeCardServer/manager/getTradeInfoList", data, "POST");

/**
 * 查询员工推荐报表
 */
export const QueryTJ = data => fetch("dataWay?apiid=QueryTJ", data, "GET");
export const dataWay = data => fetch("dataWay", data, "GET");

/**
 * 删除修补单
 */
export const sp_repair_del = data =>
    fetch("dataWay?apiid=sp_repair_del", data, "GET");
/**
 * 删除冻结解冻单
 */
export const sp_djjd_del = data =>
    fetch("dataWay?apiid=sp_djjd_del", data, "POST");
/**
 * 查询日汇总
 */
export const QueryRJ = data => fetch("dataWay?apiid=QueryRJ", data, "POST");

/**
 * 查询门店汇总支付明细
 */
export const QueryMDJX = data => fetch("dataWay?apiid=QueryMDJX", data, "POST");

/**
 * 查询修补单据列表
 */
export const getRepairBills = data =>
    fetch("rechargeCardServer/manager/getRepairBills", data, "POST");

/**
 * 查询解冻、冻结单据列表
 */
export const getFrozenBills = data =>
    fetch("rechargeCardServer/manager/getFrozenBills", data, "POST");

/**
 * 创建修补单
 */
export const insertRepairBill = data =>
    fetch("rechargeCardServer/manager/insertRepairBill", data, "POST");

/**
 * 创建解冻、冻结单
 */
export const insertFrozenBill = data =>
    fetch("rechargeCardServer/manager/insertFrozenBill", data, "POST");

/**
 * 修补单审核
 */
export const repair = data =>
    fetch("rechargeCardServer/manager/repair", data, "POST");

/**
 * 冻结、解冻单据审核
 */
export const frozen = data =>
    fetch("rechargeCardServer/manager/frozen", data, "POST");

/**
 * 增加管理员（只有admin用户有权限调用）
 */
export const addPerson = data =>
    fetch("rechargeCardServer/manager/addPerson", data, "POST");

/**
 * 查询管理员列表（只有admin用户有权限调用）
 */
export const getPersons = data =>
    fetch("rechargeCardServer/manager/getPersons", data, "POST");

/**
 * 修改管理员密码
 */
export const updatePersonPwd = data =>
    fetch("rechargeCardServer/manager/updatePersonPwd", data, "POST");

/**
 * 分页获取储值卡账户列表
 */
export const getAllAccountPage = data =>
    fetch("rechargeCardServer/manager/getAllAccountPage", data, "POST");

// 以下是pos接口 20180809
/**
 * 退出
 */

export const signout = () => fetch("/admin/singout");

/**
 * 获取用户信息
 */

export const getAdminInfo = () => fetch("/admin/info");

/**
 * api请求量
 */

export const apiCount = date => fetch("/statis/api/" + date + "/count");

/**
 * 所有api请求量
 */

export const apiAllCount = () => fetch("/statis/api/count");

/**
 * 所有api请求信息
 */

export const apiAllRecord = () => fetch("/statis/api/all");

/**
 * 用户注册量
 */

export const userCount = date => fetch("/statis/user/" + date + "/count");

/**
 * 某一天订单数量
 */

export const orderCount = date => fetch("/statis/order/" + date + "/count");

/**
 * 某一天管理员注册量
 */

export const adminDayCount = date => fetch("/statis/admin/" + date + "/count");

/**
 * 管理员列表
 */

export const adminList = data => fetch("/admin/all", data);

/**
 * 管理员数量
 */

export const adminCount = () => fetch("/admin/count");

/**
 * 获取定位城市
 */

export const cityGuess = () =>
    fetch("/v1/cities", {
        type: "guess"
    });

/**
 * 添加商铺
 */

export const addShop = data => fetch("/shopping/addShop", data, "POST");

/**
 * 获取搜索地址
 */

export const searchplace = (cityid, value) =>
    fetch("/v1/pois", {
        type: "search",
        city_id: cityid,
        keyword: value
    });

/**
 * 获取当前店铺食品种类
 */

export const getCategory = restaurant_id =>
    fetch("/shopping/getcategory/" + restaurant_id);

/**
 * 添加食品种类
 */

export const addCategory = data => fetch("/shopping/addcategory", data, "POST");

/**
 * 添加食品
 */

export const addFood = data => fetch("/shopping/addfood", data, "POST");

/**
 * category 种类列表
 */

export const foodCategory = (latitude, longitude) =>
    fetch("/shopping/v2/restaurant/category");

/**
 * 获取餐馆列表
 */

export const getResturants = data => fetch("/shopping/restaurants", data);

//获取小票格式列表 by link 20180530
export const getTickListFn = data => fetch("/tick/dataList.do", data, "POST");
export const getTickGetIdFn = data => fetch("/tick/getId.do", data, "POST");
export const saveTickFn = data => fetch("/tick/save.do", data, "POST");

//获取门店列表
export const getMallLists = data => fetch("/mall/dataList.do", data, "POST");
export const getMallTreeLists = data =>
    fetch("/mall/getTreeData.do", data, "POST");

//获取菜单列表
export const getMenuLists = data => fetch("/getMenuList.do", data, "POST");
export const getMenuTreeLists = data =>
    fetch("/sysMenu/getTreeData.do", data, "POST");

/**
 *  获取角色列表
 */
//
export const getsysRoleLists = data =>
    fetch("/sysRole/dataList.do", data, "POST");
export const saveCzyGroup = data => fetch("/sysRole/save.do", data, "POST");
//获取角色权限
export const getCzyGroupQxLists = data =>
    fetch("/czyGroupQx/dataList.do", data, "POST");
export const getRoleTreeLists = data =>
    fetch("/sysRole/getTreeData.do", data, "POST");

//获取退货原因列表
export const getrefundReasonLists = data =>
    fetch("/refundReason/dataList.do", data, "POST");

/**
 * 保存退货原因
 */
export const saveRefundReason = data =>
    fetch("/refundReason/save.do", data, "POST");
export const delRefundReason = data =>
    fetch("/refundReason/delete.do", data, "POST");

/**
 * 收款方式
 */
export const getskfsLists = data => fetch("/skfs/dataList.do", data, "POST");
export const saveSkfs = data => fetch("/skfs/save.do", data, "POST");
export const delSkfs = data => fetch("/skfs/delete.do", data, "POST");
export const getskfsTypeLists = data =>
    fetch("/skfs/getSkfsTypeList.do", data, "POST");

/**
 * 店铺信息
 */
export const getshopLists = data =>
    fetch("/shopDef/getShopList.do", data, "POST");
export const getshopOne = data => fetch("/shopDef/getId.do", data, "POST");
export const getshopOne1 = data =>
    fetch("/shopDef/getAllIdByid.do", data, "POST");
export const getshopOneByFid = data =>
    fetch("/shopDef/getIdByFid.do", data, "POST");
export const saveShop = data => fetch("/shopDef/save.do", data, "POST");
export const deleteShop = data => fetch("/shopDef/delete.do", data, "POST");
export const getshopListsForSel = data =>
    fetch("/shopDef/getShopListForSelect.do", data, "POST");
export const getshopListsForTree = data =>
    fetch("/shopDef/getShopListForTree.do", data, "POST");

/**
 * 商品分类定义
 */
export const getspflLists = data =>
    fetch("/spflDef/getSpflList.do", data, "POST");
export const getspflOne = data => fetch("/spflDef/getId.do", data, "POST");
export const getspflOne1 = data =>
    fetch("/spflDef/getAllIdByid.do", data, "POST");
export const getspflOneByFid = data =>
    fetch("/spflDef/getIdByFid.do", data, "POST");
export const saveSpfl = data => fetch("/spflDef/save.do", data, "POST");
export const deleteSpfl = data => fetch("/spflDef/delete.do", data, "POST");
export const getspflListsForSel = data =>
    fetch("/spflDef/getShopListForSelect.do", data, "POST");
export const getspflListsForTree = data =>
    fetch("/spflDef/getShopListForTree.do", data, "POST");

/**
 * 商品商标信息
 */
export const getSpsbLists = data => fetch("/spsbDef/dataList.do", data, "POST");
//export const getSktOne = data => fetch('/skt/getId.do', data, 'POST');
export const saveSpsb = data => fetch("/spsbDef/save.do", data, "POST");
export const deleteSpsb = data => fetch("/spsbDef/delete.do", data, "POST");
/**
 * 收款台信息
 */
export const getSktLists = data => fetch("/skt/dataList.do", data, "POST");
export const getSktOne = data => fetch("/skt/getId.do", data, "POST");
export const saveSkt = data => fetch("/skt/save.do", data, "POST");
export const deleteSkt = data => fetch("/skt/delete.do", data, "POST");
export const getSkfsBySktno = data =>
    fetch("/sktSkfs/getSkfsBySktno.do", data, "POST");

/**
 * 商品信息
 */
export const getGoodsLists = data => fetch("/goods/dataList.do", data, "POST");
//export const getSktOne = data => fetch('/skt/getId.do', data, 'POST');
export const saveGoods = data => fetch("/goods/save.do", data, "POST");
//export const deleteSkt = data => fetch('/skt/delete.do', data, 'POST');
//export const getSkfsBySktno = data => fetch('/sktSkfs/getSkfsBySktno.do', data, 'POST');

/**
 * 人员信息
 */
export const getPersonLists = data =>
    fetch("/personInfo/dataList.do", data, "POST");
export const makeXtczy = data => fetch("/personInfo/saveCzy.do", data, "POST");
export const savePerson = data => fetch("/personInfo/save.do", data, "POST");
export const deletePerson = data =>
    fetch("/personInfo/delete.do", data, "POST");

/**
 * 操作员管理
 */
export const getXtczyLists = data => fetch("/xtczy/dataList.do", data, "POST");
//export const makeXtczy = data => fetch('/personInfo/saveCzy.do', data, 'POST');
export const saveXtczy = data => fetch("/xtczy/save.do", data, "POST");
export const saveXtczyStatus = data =>
    fetch("/xtczy/saveStatus.do", data, "POST");
export const deleteXtczy = data => fetch("/xtczy/delete.do", data, "POST");
//获取操作员店铺权限
export const getXtczyBmqxLists = data =>
    fetch("/xtczyBmqx/dataList.do", data, "POST");
export const getXtczyMcqxLists = data =>
    fetch("/xtczyMcqx/dataList.do", data, "POST");

/**
 * 优惠券定义
 */
export const getCoupDefLists = data =>
    fetch("/coupDef/dataList.do", data, "POST");
export const getCoupDefAllLists = data =>
    fetch("/coupDef/getAllList.do", data, "POST");

/**
 * 优惠券发券规则管理
 */
export const getCoupGrantRuleLists = data =>
    fetch("/coupGrantRule/dataList.do", data, "POST");
export const saveCoupGrantRuleLists = data =>
    fetch("/coupGrantRule/save.do", data, "POST");
export const deleteCoupGrantRule = data =>
    fetch("/coupGrantRule/delete.do", data, "POST");
export const disableCoupGrantRule = data =>
    fetch("/coupGrantRule/updateStatus.do", data, "POST");
export const getCoupGrantRuleItem = data =>
    fetch("/coupGrantRule/getItemById.do", data, "POST");
export const getGrantRuleForSel = data =>
    fetch("/coupGrantRule/ruleQueryForSelect.do", data, "POST");

/**
 * 优惠券用券规则管理
 */
export const getCoupPayRuleLists = data =>
    fetch("/coupPayRule/dataList.do", data, "POST");
export const saveCoupPayRuleLists = data =>
    fetch("/coupPayRule/save.do", data, "POST");
export const deleteCoupPayRule = data =>
    fetch("/coupPayRule/delete.do", data, "POST");
export const disableCoupPayRule = data =>
    fetch("/coupPayRule/updateStatus.do", data, "POST");
export const getCoupPayRuleItem = data =>
    fetch("/coupPayRule/getItemById.do", data, "POST");
export const getPayRuleForSel = data =>
    fetch("/coupPayRule/ruleQueryForSelect.do", data, "POST");

/**
 * 优惠券发券单据管理
 */
export const getYhqffdLists = data =>
    fetch("/yhqffd/dataList.do", data, "POST");
export const saveYhqffd = data => fetch("/yhqffd/save.do", data, "POST");
export const saveYhqffdGzdx = data =>
    fetch("/yhqffdGzdx/save.do", data, "POST");
export const delYhqffdGzdx = data =>
    fetch("/yhqffdGzdx/deleteOne.do", data, "POST");
export const getYhqffdGzdxLists = data =>
    fetch("/yhqffd/getItemById.do", data, "POST");
export const getYhqffdDpLists = data =>
    fetch("/yhqffdGzdx/getItemById.do", data, "POST");
export const disableYhqffd = data =>
    fetch("/yhqffd/updateStatus.do", data, "POST");
export const deleteYhqffd = data => fetch("/yhqffd/delete.do", data, "POST");
//export const disableCoupPayRule = data => fetch('/coupPayRule/updateStatus.do', data, 'POST');
//export const getCoupPayRuleItem = data => fetch('/coupPayRule/getItemById.do', data, 'POST');

/**
 * 优惠券用券单据管理
 */
export const getYhqsydLists = data =>
    fetch("/yhqsyd/dataList.do", data, "POST");
export const saveYhqsyd = data => fetch("/yhqsyd/save.do", data, "POST");
export const saveYhqsydGzdx = data =>
    fetch("/yhqsydGzdx/save.do", data, "POST");
export const delYhqsydGzdx = data =>
    fetch("/yhqsydGzdx/deleteOne.do", data, "POST");
export const getYhqsydGzdxLists = data =>
    fetch("/yhqsyd/getItemById.do", data, "POST");
export const getYhqsydDpLists = data =>
    fetch("/yhqsydGzdx/getItemById.do", data, "POST");
export const disableYhqsyd = data =>
    fetch("/yhqsyd/updateStatus.do", data, "POST");
export const deleteYhqsyd = data => fetch("/yhqsyd/delete.do", data, "POST");

/************************************** 报表部分 ************************************* */

/**
 * POS销售明细
 */
export const getShopSaleDetailLists = data =>
    fetch("/shopSaleDetail/dataList.do", data, "POST");
export const getShopSaleDetailLists_Spxx = data =>
    fetch("/shopSaleDetail/getDetails.do", data, "POST");

/**
 * 获取餐馆详细信息
 */
export const getResturantDetail = restaurant_id =>
    fetch("/shopping/restaurant/" + restaurant_id);

/**
 * 获取餐馆数量
 */

export const getResturantsCount = () => fetch("/shopping/restaurants/count");

/**
 * 更新餐馆信息
 */

export const updateResturant = data =>
    fetch("/shopping/updateshop", data, "POST");
/**
 * 保存门店信息
 */

export const saveMalldef = data => fetch("/mall/save.do", data, "POST");

/**
 * 删除餐馆
 */

export const deleteResturant = restaurant_id =>
    fetch("/shopping/restaurant/" + restaurant_id, {}, "DELETE");

/**
 * 获取食品列表
 */

export const getFoods = data => fetch("/shopping/v2/foods", data);

/**
 * 获取食品数量
 */

export const getFoodsCount = data => fetch("/shopping/v2/foods/count", data);

/**
 * 获取menu列表
 */

export const getMenu = data => fetch("/shopping/v2/menu", data);

/**
 * 获取menu详情
 */

export const getMenuById = category_id =>
    fetch("/shopping/v2/menu/" + category_id);

/**
 * 更新食品信息
 */

export const updateFood = data =>
    fetch("/shopping/v2/updatefood", data, "POST");

/**
 * 删除食品
 */

export const deleteFood = food_id =>
    fetch("/shopping/v2/food/" + food_id, {}, "DELETE");

/**
 * 获取用户列表
 */

export const getUserList = data => fetch("/v1/users/list", data);

/**
 * 获取用户数量
 */

export const getUserCount = data => fetch("/v1/users/count", data);

/**
 * 获取订单列表
 */

export const getOrderList = data => fetch("/bos/orders", data);

/**
 * 获取订单数量
 */

export const getOrderCount = data => fetch("/bos/orders/count", data);

/**
 * 获取用户信息
 */

export const getUserInfo = user_id => fetch("/v1/user/" + user_id);

/**
 * 获取地址信息
 */

export const getAddressById = address_id => fetch("/v1/addresse/" + address_id);

/**
 * 获取用户分布信息
 */

export const getUserCity = () => fetch("/v1/user/city/count");
